package com.skateboard.reelviewtest.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.skateboard.reelviewtest.R;

import java.util.ArrayList;
import java.util.List;

/**
 * @作者： xuze
 * @时间： 2020/11/19 2:51 PM
 * @描述：
 */
public class List3DRotate2Adapter extends RecyclerView.Adapter {
    public List<String>list=new ArrayList<>();
    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item2_recycleview_3d,parent,false);
        ViewHolder holder = new ViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
        ((ViewHolder)holder).relativeLayout1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mOnItemClickLitener!=null){
                    mOnItemClickLitener.onItemClick(((ViewHolder)holder).rootView,position);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return 30;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        public RelativeLayout relativeLayout1;
        public RelativeLayout relativeLayout2;
        public RelativeLayout rootView;
        public ViewHolder (View view) {
            super(view);
            relativeLayout1 = view.findViewById(R.id.item_1);
            relativeLayout2 = view.findViewById(R.id.item_2);
            rootView=view.findViewById(R.id.rootView);
        }
    }

    private OnItemClickLitener   mOnItemClickLitener;

    //设置回调接口
    public interface OnItemClickLitener{
        void onItemClick(View view, int position);
    }

    public void setmOnItemClickLitener(OnItemClickLitener mOnItemClickLitener) {
        this.mOnItemClickLitener = mOnItemClickLitener;
    }
}
